import { Key } from "react"; 
// 引入axios请求
import { request } from "@/utils/http";

// 引入数据类型
import { 
    getHospitalSetlistParamsType,
    getHospitalSetlistReturnType,
    addHospitalParamType,
    getHosSetListItemsType,
    updateHospitalParamType
} from "./model/hospitalSetType";

// 医院设置中, 获取分页列表的请求
// 注意:之后所有的请求都是一样的,给形参和返回值定义数据类型
export const getHospitalSetlistRequest = ({ page, limit, hosname, hoscode }: getHospitalSetlistParamsType) => {
    return request.get<any, getHospitalSetlistReturnType>(`/admin/hosp/hospitalSet/${page}/${limit}`, {
        params: {
            hosname,
            hoscode
        }
    })
}

// 医院设置中, 新增医院数据的post请求
export const addHospitalRequest=(data:addHospitalParamType)=>{
    return request.post<any,null>('/admin/hosp/hospitalSet/save',data)
}

// 医院设置中,点击修改按钮根据id获取某个详细的医院设置
export const getHosSetFromIdRequest = (id:string)=>{
    return request.get<any,getHosSetListItemsType>(`/admin/hosp/hospitalSet/get/${id}`)
}

// 医院设置中,根据id修改数据后,再次将修改过后的数据提交
// put请求没有返回值,所以也不需要设置返回值的数据类型
export const updateHosSetFromIdRequest=(data:updateHospitalParamType)=>{
    return request.put<any,null>('/admin/hosp/hospitalSet/update',data)
}

// 医院设置中,删除医院数据的api
export const deleteHosSetIdRequest=(id:string)=>{
    return request.delete<any,null>(`/admin/hosp/hospitalSet/remove/${id}`)
}

// 医院设置中,批量删除医院数据的api
export const deleteDataBatchesRequest=(ids:Key[])=>{
    return request.delete<any,null>('/admin/hosp/hospitalSet/batchRemove',{
        data:ids
    })
}